package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Phone    string `gorm:"type:varchar(30);not null"`
	Password string `gorm:"type:varchar(200);not null"`
	Age      int64  `gorm:"type:int(11);not null"`
	Address  string `gorm:"type:varchar(100);not null"`
}

func (u *User) FindUserByPhone(db *gorm.DB, phone string) error {
	return db.Debug().Where("phone=?", phone).Find(u).Error
}

func (u *User) UserDetail(db *gorm.DB, id int64) error {
	return db.Debug().Where("id=?", id).First(u).Error
}

func (u *User) UserUpdate(db *gorm.DB, id int64) error {
	return db.Debug().Where("id=?", id).Updates(u).Error
}
